//****************************************************************************
//
// timing example
//
//****************************************************************************

#configure board        hu_arm_v4
#configure clcd_lines   2
#configure memory       rom
#configure baudrate     38400

#include "pRTOS.h"
#include "armboard.h"

int main( void ){
   RTOS::run();
   return 0;
}

// end of standard part

class leds_task : public RTOS::task {
public:
   RTOS::timer shift, invert;
   leds_task( void ): shift( this ), invert( this ){}
private:   
   void main( void ){
      int n = 0x03, polarity = 0;
      shift.set( 88 MS );
      invert.set( 5 S );
      for(;;){      
         RTOS::event e = wait(); 
         if( shift == e ){ 
		   n = (( n << 1 ) | ( n >> 7 )) & 0xFF; 
		   shift.set( 88 MS );
		 }
	     if( invert == e ){ 
		    polarity ^= 0xFF; 
    	    invert.set( 5 S );
		 }
    	 armboard::LEDs::write( n ^ polarity );
	 }
   }
};
leds_task leds;


